Skip to content

feat(api): add conversation list and detail endpoints with pagination - #18

Open
johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-17-conversation-list-endpoints
Open

johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-17-conversation-list-endpoints

Conversation

@johnnyhuy

Copy link
Copy Markdown
Contributor

What changed

Adds read-only conversation endpoints so the dashboard can inspect past Wingman conversations. GET /api/conversations returns one summary per distinct conversation with a total count, and GET /api/conversations/{conversation_id} returns its turns in chronological order. Both support limit and offset pagination.

Part of #5
Closes #17

How it was verified

  • mise run install - passed after recreating the worktree venv with the mise-pinned Python 3.13 (the default Python 3.14 cannot install onnxruntime, same note as the previous run; no lockfile change kept)
  • mise run test-backend - 57 passed, including 10 new tests in backend/tests/test_conversations.py (TestListConversations 6, TestConversationDetail 4)
  • mise run test-frontend - passed (the repo task currently reports no frontend tests yet)
  • Offline HTTP proof against the local backend (see below). Slack auth was stubbed with the repo test pattern from backend/tests/test_logging.py, so nothing connected to a live workspace. The backend startup log showed "Starting Wingman backend..." and "Database initialized" before serving.

Proof

Backend started locally with a sqlite database seeded with two fixture conversations, Slack auth stubbed offline.

List, most recently active first:

$ curl -s http://127.0.0.1:8765/api/conversations
{"items":[{"conversation_id":"conv-b","channel_id":"C2","message_count":1,"first_message_at":"2026-01-01T09:02:00","last_message_at":"2026-01-01T09:02:00","last_message_preview":"When is the office open?"},{"conversation_id":"conv-a","channel_id":"C1","message_count":2,"first_message_at":"2026-01-01T09:00:00","last_message_at":"2026-01-01T09:01:00","last_message_preview":"Use the IT portal."}],"total":2,"limit":50,"offset":0}

Detail in chronological order:

$ curl -s http://127.0.0.1:8765/api/conversations/conv-a
{"conversation_id":"conv-a","items":[{"id":1,"conversation_id":"conv-a","user_id":"U1","channel_id":"C1","role":"user","message":"How do I reset VPN?","message_ts":null,"created_at":"2026-01-01T09:00:00"},{"id":2,"conversation_id":"conv-a","user_id":"U1","channel_id":"C1","role":"assistant","message":"Use the IT portal.","message_ts":null,"created_at":"2026-01-01T09:01:00"}],"total":2,"limit":50,"offset":0}

Missing conversation and invalid pagination:

$ curl -s http://127.0.0.1:8765/api/conversations/missing
{"detail":"Conversation not found"} HTTP:404

$ curl -s "http://127.0.0.1:8765/api/conversations?limit=0"
{"detail":[{"type":"greater_than_equal","loc":["query","limit"],"msg":"Input should be greater than or equal to 1","input":"0","ctx":{"ge":1}}]} HTTP:422

Reviewer notes

  • Read-only slice. No dashboard UI, no write or delete endpoints, and no migration. The new test file is wired into mise run test-backend in mise.toml so CI gates it.
  • Nothing user-facing in the frontend changed in this slice, so there is no screenshot. The capture method that succeeded was backend (a). Frontend capture (b) was not applicable.
  • Full verification against a live Slack workspace is not needed for this slice, since conversations are read from the local database only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add conversation list and detail endpoints with pagination

1 participant